#!/usr/bin/env xonsh

from os.path import join,dirname

PWD = dirname(__file__)

cd @(PWD)

git add -u

git commit -m.

npm version patch -m'.'

cat package.json | jq ".version" | tr -d '"' > version

npx coffee -bc -o lib src/

with open("version") as version:
  version = version.read().strip()
  txt = []
  main = "lib/main.js"
  with open(main) as f:
    for i in f.read().split("\n"):
      if i.find("@version") >= 0:
        txt.append(f"// @version {version}")
      else:
        txt.append(i)
  with open(main,"w") as f:
    f.write("\n".join(txt))


git add --update :/ && git commit -m "🔶"

git pull origin master

git push --tag --set-upstream origin master -f


